<?php
namespace Trawind\Shares\Models;

use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

class Shares extends Model implements Transformable
{
    use TransformableTrait;

    protected $dateFormat = 'U';

    protected $table = 'shares';

    //    organization type
    const TYPE_USER = 11;
    const TYPE_COMPANY = 12;
    const TYPE_DEPARTMENT = 13;
    const TYPE_LOCATION = 14;
    const TYPE_CHANNEL = 15;


    const ORGANIZATION_TYPE_LIST = [
        Shares::TYPE_USER => "user",
        Shares::TYPE_COMPANY => "company",
        Shares::TYPE_DEPARTMENT => "department",
        Shares::TYPE_LOCATION => "location",
        Shares::TYPE_CHANNEL => "channel",
    ];

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'external_id',
        'business_type',
        'business_id',
        'organization_type_id',
        'organization_id',
        'parent_subsidiary_id',
        'origin_business_type_id',
        'origin_business_id',
        'status_type_id',
        'user_id',
        'subsidiary_id',
        'department_id',
        'location_id',
        'channel_id',
        'created_at',
        'updated_at',
    ];
    /**
     *
     */
    public function business()
    {
        return $this->morphTo();
    }

}
